import idraw.*;
import geometry.*;
import tester.*;
import java.util.*;
import colors.*;

class ConsLoS implements ILoS{
	Star first;
	ILoS rest;

	//draws the whole wide list of stars.
	public void drawStars(Canvas c){
		this.first.drawStar(c);
		this.rest.drawStars(c);
	}

	//"map"s onTick across a list of stars.
	public void onTick(Mfmwg m){
		if (this.first.span <= 0 || this.first.isFoundp(m) || this.first.hitGroundp()){
			first = this.first.makeStar();
			this.rest.onTick(m);
		} else { 
			this.first.onTick();
			this.rest.onTick(m);
		}
	}

	//have any of the stars been found?
	public boolean foundStar(Mfmwg m){
		return this.first.isFoundp(m) || this.rest.foundStar(m);
	}

	//return the first star that can be caught.
	//don't break it!
	public Star caughtStar(Mfmwg m){
		if(this.first.isFoundp(m)) {
			return this.first;
		} else { return this.rest.caughtStar(m);
		}
	}

	ConsLoS(Star first, ILoS rest) {
		this.first = first;
		this.rest = rest;
	}

	/*
TEMPLATE:
   FIELDS:
    ... this.first ...            --Star
    ... this.rest ...             --ILoS

    METHODS:
    ... this.drawStars(Canvas c) ...  -- boolean
    ... this.onTick(Mfmwg m) ...      -- ILoS
    ... this.foundStar(Mfmwg m) ...   -- boolean
    ... this.caughtStar(Mfmwg m) ...  -- boolean


    METHODS FOR FIELDS:
    ... this.first.onTick() ...             -- Star
    ... this.first.makeStar() ...           -- Star
    ... this.first.hitGroundp() ...         -- boolean
    ... this.first.isFoundp(Mfmwg m) ...    -- boolean
    ... this.first.drawStar(Canvas c) ...   -- boolean
    ... this.rest.drawStars(Canvas c) ...  -- boolean
    ... this.rest.onTick(Mfmwg m) ...      -- ILoS
    ... this.rest.foundStar(Mfmwg m) ...   -- boolean
    ... this.rest.caughtStar(Mfmwg m) ...  -- boolean
	 */ 
}